/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * RecuperacaoCredito.java
 *
 * Created on 12/05/2009, 18:44:07
 */

package apresentacao;

import dados.CarregarDados;
import dados.RepositorioCliente;
import dados.RepositorioDevedor;
import negocio.AcoesCliente;
import negocio.AcoesDevedor;
import negocio.excecoes.ClienteJaExisteException;
import negocio.excecoes.ClienteNaoExisteException;

/**
 *
 * @author 20081169212
 */
public class RecuperacaoCredito extends javax.swing.JFrame {
    private static RecuperacaoCredito rc;
    AcoesCliente acCliente;
    AcoesDevedor acDevedor;
    /** Creates new form RecuperacaoCredito */
    public RecuperacaoCredito() {
        acCliente = new AcoesCliente(new RepositorioCliente());
        acDevedor = new AcoesDevedor(new RepositorioDevedor());
        initComponents();
        CarregarDados c = new CarregarDados();
        try {
            acCliente.Cadastrar(c.c1);
            acCliente.Cadastrar(c.c2);
            acCliente.Cadastrar(c.c3);
        } catch (ClienteJaExisteException ex) {
            //
        } catch (ClienteNaoExisteException ex){
            
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Sistema de Recuperação de Credito");

        jMenu1.setText("Cadastro");

        jMenuItem1.setText("Cliente");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuItem4.setText("Devedor");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem4);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Consultas");

        jMenuItem3.setText("Cliente");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem3);

        jMenuItem5.setText("Devedor");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem5);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Sistema");

        jMenuItem2.setText("Sair");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem2);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 800, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 569, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        TelaCadCliente tlCadLoja = new TelaCadCliente(acCliente);
        tlCadLoja.setVisible(true);
        tlCadLoja.setLocation((rc.getWidth() - tlCadLoja.getSize().width)/2,
                      (rc.getHeight() - tlCadLoja.getSize().height)/2);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        System.exit(EXIT_ON_CLOSE);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        TelaConsultaCliente tlConsLoja = new TelaConsultaCliente(acCliente);
        tlConsLoja.setVisible(true);
        tlConsLoja.setLocation((rc.getWidth() - tlConsLoja.getSize().width)/2,
                      (rc.getHeight() - tlConsLoja.getSize().height)/2);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        TelaConsultaDevedor tlConsDevedor = new TelaConsultaDevedor(acDevedor);
        tlConsDevedor.setVisible(true);
        tlConsDevedor.setLocation((rc.getWidth() - tlConsDevedor.getSize().width)/2,
                      (rc.getHeight() - tlConsDevedor.getSize().height)/2);
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
     TelaCadDevedor tlCadDevedor = new TelaCadDevedor(acDevedor);
     tlCadDevedor.setVisible(true);
     tlCadDevedor.setLocation((rc.getWidth() - tlCadDevedor.getSize().width)/2,
                      (rc.getHeight() - tlCadDevedor.getSize().height)/2);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                rc = new RecuperacaoCredito();
                rc.setVisible(true);
                rc.setExtendedState(MAXIMIZED_BOTH);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    // End of variables declaration//GEN-END:variables

}
